home *** CD-ROM | disk | FTP | other *** search
- Path: pegasus.montclair.edu!harmon
- From: harmon@pegasus.montclair.edu (Derek Harmon)
- Newsgroups: comp.lang.c
- Subject: Re: What wrong!
- Date: 13 Feb 1996 18:19:55 -0500
- Organization: Montclair State University
- Message-ID: <harmon.824252266@pegasus.montclair.edu>
- References: <4fpa2g$ebg@ratree.psu.ac.th>
- NNTP-Posting-Host: pegasus.montclair.edu
- X-Newsreader: NN version 6.5.0 #68 (NOV)
-
- s3610165@maliwan.psu.ac.th (Sanon CHAOCHAIYAPORN) writes:
- >will clear and appear dos prompt but it is not follow that. My program will
- >appear error message,"BGI Error: Graphics not initialized (use'initgraph')".
- ^\_ Borland Graphics Interface (MS-DOS specific)
-
- >Who can help me? Please, advice to me...
-
- As this is specific to Borland's graphics.h, you would have better luck
- asking in comp.os.msdos.programmer or rec.games.programmer.
-
- > int gd = DETECT;
- > int gm = getgraphmode();
- ^^^^^!^^^^^^^^
- Your error no doubt occurs here. You call initgraph() later on in your
- program, but this is the 2nd line that gets executed. initgraph() must be
- called before any other BGI functions. It is alright for gm to be uninit-
- ialized when you make a call to initgraph(), it is part of initgraph()'s
- responsibilities to initialize gm for you. Replace with,
-
- : int gm;
-
- and your program will run. It would also be wise to use graphresult()
- after initgraph() and test for grOK, in case initgraph() fails for any
- reason.
-
- > clrscr(); /* this is not necessary, initgraph() will clear everything */
- > initgraph(&gd,&gm,"c:\\winapp\\tc");
- : if (graphresult() != grOk) {
- : puts("Graphics Error.");
- : exit(1);
- : } /* it'd be even better to save graphresult() to a variable and then
- : * print grapherrormsg(). */
-
- > do
- > {
- > initgraph(&gd,&gm,"c:\\winapp\\tc");
-
- Oh, and something bad will probably happen if you leave this in here, you
- shouldn't call initgraph() more than once in an application.
-
- -- Stone
- --
- # Derek Harmon (aka Stonelight) harmon@pegasus.montclair.edu
- # - Computer Science Undergrad, Montclair State University, NJ
- # - My views are my own, nobody else is this creative. 3;)>
- ... Buy land today, it's not being made anymore.
-